package com.wu.web;

import com.wu.service.UserService;
import com.wu.service.impl.UserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 查询用户名是否重复
 */
@WebServlet("/RegistUserName")
public class RegistUserNameServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String UserName=req.getParameter("username");

        UserService userService=new UserServiceImpl();
        if (!userService.existsUssername(UserName))
        {
            resp.getWriter().print("ok");
        }else
        {
            resp.getWriter().print("no");
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
